package net.worldscale.xp.wslib.wstest;

import java.io.PrintStream;
import java.util.Enumeration;
import java.util.Vector;


public class TestCaseSuite {

    private final Vector<TestCase> mCaseList = new Vector<TestCase>();

    public TestCaseSuite() {
    }

    public void addCase(TestCase tc) {
        this.mCaseList.addElement(tc);
    }

    public void startAll(PrintStream ps) {
        if (ps == null) {
            ps = System.out;
        }
        int index = 0;
        ps.println("<TestCaseSet>");
        for (final Enumeration<TestCase> enu = this.mCaseList.elements(); enu.hasMoreElements();) {
            final TestCase tc = enu.nextElement();
            ps.println("<TestCase>");
            ps.println("<index>" + (++index) + "</index>");
            ps.println("<name>" + tc.getName() + "</name>");
            ps.println("<class>" + tc.getClass().getName() + "</class>");
            ps.println("<timestamp>"
                    + TestCase.timestampToString(System.currentTimeMillis())
                    + "</timestamp>");
            ps.println("<![CDATA[");
            tc.start(ps);
            ps.println("]]>");
            ps.println("</TestCase>");
        }
        ps.println("</TestCaseSet>");

    }
}
